import { createApp } from 'vue'
import { registerGlobComp } from '@/components'
import AppComp from './App.vue'
import { setupGlobDirectives } from './directives'
import { setupI18n } from './locales'
import { setupAntd } from './plugins/antd'
import { setupRouter } from './router'
import { setupStore } from './stores'
import { App } from './utils/app'

/**
 * 启动app
 */
export const bootstrap = async () => {
  // 初始化应用
  await App.getInstance().init()

  // 创建vue对象
  const app = createApp(AppComp)

  // 注册全局组件
  registerGlobComp(app)

  // 国际化 i18n 配置
  await setupI18n(app)

  // 配置 pinia-tore
  await setupStore(app)

  // 注册antd框架组件和方法
  setupAntd(app)

  // 路由
  setupRouter(app)

  // 注册全局指令
  setupGlobDirectives(app)

  // 挂载
  app.mount('#app')
}
